//
//  Metal.cpp
//  Chart
//
//  Created by CaoJun on 13-6-3.
//
//

#include "Config.h"
#include "Metal.h"

using namespace ytx;
using namespace std;


Metal::Metal(string name, string nickname,
             int dataSum, string marketType, string id, string currentDate, int stepDay,
             TimeString timeString, Rect row, Rect column, YTXTime openTime, YTXTime closeTime, vector<pair<YTXTime, YTXTime> > restTime, map<IndexType::IndexType, IndexConfig> indexConfig, int toFix, bool hasVolume, int threshold,int buffer)
:name(name),
nickname(nickname),
dataSum(dataSum),
marketType(marketType),
id(id),
currentDate(currentDate),
stepDay(stepDay),
timeString(timeString),
row(row),
column(column),
threshold(threshold),
buffer(buffer),
openTime(openTime),
closeTime(closeTime),
restTime(restTime),
indexConfig(indexConfig),
toFix(toFix),
hasVolume(hasVolume)
{
    
}

vector<Metal> __attribute__((annotate("oclint:suppress[long method]"))) __attribute__((annotate("oclint:suppress[high ncss method]")))Metal::initCollection(){
    const TimeString zsj_r = createTimeStringByTimeType(MarketTimeType::Fromzsj_r);
    const TimeString zsj_y = createTimeStringByTimeType(MarketTimeType::Fromzsj_y);
    const TimeString dsj_r = createTimeStringByTimeType(MarketTimeType::Fromdsj_r);
    const TimeString dsj_y = createTimeStringByTimeType(MarketTimeType::Fromdsj_y);
    const TimeString sqj_r = createTimeStringByTimeType(MarketTimeType::Fromsqj_r);
    const TimeString sqj_y0 = createTimeStringByTimeType(MarketTimeType::Fromsqj_y0);
    const TimeString sqj_y1 = createTimeStringByTimeType(MarketTimeType::Fromsqj_y1);
    const TimeString sqj_y2 = createTimeStringByTimeType(MarketTimeType::Fromsqj_y2);
    const TimeString zjqj_r0 = createTimeStringByTimeType(MarketTimeType::Fromzjqj_r0);
    const TimeString zjqj_r1 = createTimeStringByTimeType(MarketTimeType::Fromzjqj_r1);
    const TimeString ts_ttj = createTimeStringByTimeType(MarketTimeType::From0600To0400);
    const TimeString ts_shj = createTimeStringByTimeType(MarketTimeType::From2000To1530);
    const TimeString ts_gjj = createTimeStringByTimeType(MarketTimeType::From0600To0600);
    const TimeString ts_gdj = createTimeStringByTimeType(MarketTimeType::From0600To0400);
    const TimeString ts_lme = createTimeStringByTimeType(MarketTimeType::From0800To0200);
    const TimeString ts_shfe = createTimeStringByTimeType(MarketTimeType::From2100To1500);
    const TimeString ts_gbs = createTimeStringByTimeType(MarketTimeType::From0930To1500);

    YTXTime originTime(2001, 1, 1, 0, 0, 0 );

    YTXTime nextTime(originTime+ytx::days(1));

    YTXTime date_ttj = YTXTime::initByDateAndTimeOfDay(originTime, 6, 0, 0);
    YTXTime date_shj = YTXTime::initByDateAndTimeOfDay(originTime, 20, 0, 0);
    YTXTime date_gjj = YTXTime::initByDateAndTimeOfDay(originTime, 6, 0, 0);
    YTXTime date_gdj = YTXTime::initByDateAndTimeOfDay(originTime, 6, 0, 0);
    YTXTime date_lme = YTXTime::initByDateAndTimeOfDay(originTime, 9, 0, 0);
    YTXTime date_shfe = YTXTime::initByDateAndTimeOfDay(originTime, 21, 0, 0);
    YTXTime date_gbs = YTXTime::initByDateAndTimeOfDay(originTime, 9, 30, 0);

    YTXTime date_ttj_end = YTXTime::initByDateAndTimeOfDay(nextTime, 4, 0, 0);
    YTXTime date_shj_end = YTXTime::initByDateAndTimeOfDay(nextTime, 15 ,30 , 0);
    YTXTime date_gjj_end = YTXTime::initByDateAndTimeOfDay(nextTime, 6, 0, 0);
    YTXTime date_gdj_end = YTXTime::initByDateAndTimeOfDay(nextTime, 4, 0, 0);
    YTXTime date_lme_end = YTXTime::initByDateAndTimeOfDay(nextTime, 3, 0, 0);
    YTXTime date_shfe_end = YTXTime::initByDateAndTimeOfDay(nextTime, 15 ,0, 0);
    YTXTime date_gbs_end = YTXTime::initByDateAndTimeOfDay(nextTime, 15 ,0, 0);
    
    vector<Metal> ret;
    
    vector<pair<YTXTime, YTXTime> > restTime;
    
    map<IndexType::IndexType, IndexConfig> indexConfig = IndexConfig::initIndex();
    
    ret.push_back(Metal::createMetal("现货白银", "XAGUSD", "TPME", "TPME.XAGUSD",YTXTime().toStringYYYYMMdd(), true, ts_ttj,date_ttj, date_ttj_end, restTime, indexConfig, 0, false));
    ret.push_back(Metal::createMetal("现货钯金", "PD", "TPME", "TPME.PD",YTXTime().toStringYYYYMMdd(), true, ts_ttj, date_ttj, date_ttj_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("现货铂金", "PT", "TPME", "TPME.PT",YTXTime().toStringYYYYMMdd(), true, ts_ttj, date_ttj, date_ttj_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("现货镍", "NI", "TPME", "TPME.NI", YTXTime().toStringYYYYMMdd(), true, ts_ttj, date_ttj, date_ttj_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("现货铜", "CU", "TPME", "TPME.CU", YTXTime().toStringYYYYMMdd(), true, ts_ttj, date_ttj, date_ttj_end, restTime, indexConfig, 0, false));
    ret.push_back(Metal::createMetal("现货铝", "AL", "TPME", "TPME.AL", YTXTime().toStringYYYYMMdd(), true, ts_ttj, date_ttj, date_ttj_end, restTime, indexConfig, 0, false));
    
    vector<pair<YTXTime, YTXTime> > shjRestTime;
    
    YTXTime restshj00 = YTXTime::initByDateAndTimeOfDay(nextTime, 2, 30, 0);//02:30
    YTXTime restshj01 = YTXTime::initByDateAndTimeOfDay(nextTime, 9, 0, 0);//09:00
    
    YTXTime restshj10 = YTXTime::initByDateAndTimeOfDay(nextTime, 11, 30, 0);//11:30
    YTXTime restshj11 = YTXTime::initByDateAndTimeOfDay(nextTime, 13, 30, 0);//09:00
    
    shjRestTime.push_back(make_pair(restshj00, restshj01));
    
    shjRestTime.push_back(make_pair(restshj10, restshj11));
    
    vector<pair<YTXTime, YTXTime> > shfeRestTime;
    
    YTXTime restshfe00 = YTXTime::initByDateAndTimeOfDay(nextTime, 2, 30, 0);
    YTXTime restshfe01 = YTXTime::initByDateAndTimeOfDay(nextTime, 9, 0, 0);
    
    YTXTime restshfe10 = YTXTime::initByDateAndTimeOfDay(nextTime, 11, 30, 0);
    YTXTime restshfe11 = YTXTime::initByDateAndTimeOfDay(nextTime, 13, 30, 0);
    
    shfeRestTime.push_back(make_pair(restshfe00, restshfe01));
    
    shfeRestTime.push_back(make_pair(restshfe10, restshfe11));
    
    ret.push_back(Metal::createMetal("黄金延期", "AUT+D", "SGE", "SGE.AUT+D", YTXTime().toStringYYYYMMdd(), true, ts_shj, date_shj, date_shj_end, shjRestTime, indexConfig, 2, true));
    ret.push_back(Metal::createMetal("白银延期", "AGT+D", "SGE", "SGE.AGT+D", YTXTime().toStringYYYYMMdd(), true, ts_shj, date_shj, date_shj_end, shjRestTime, indexConfig, 0, true));
    ret.push_back(Metal::createMetal("黄金9999", "AU9999", "SGE", "SGE.AU9999", YTXTime().toStringYYYYMMdd(), true, ts_shj, date_shj, date_shj_end, shjRestTime, indexConfig, 2, true));
    ret.push_back(Metal::createMetal("黄金9995", "AU9995", "SGE", "SGE.AU9995", YTXTime().toStringYYYYMMdd(), true, ts_shj, date_shj, date_shj_end, shjRestTime, indexConfig, 2, true));
    ret.push_back(Metal::createMetal("100克金条", "AU100G", "SGE", "SGE.AU100G", YTXTime().toStringYYYYMMdd(), true, ts_shj, date_shj, date_shj_end, shjRestTime, indexConfig, 2, true));
    ret.push_back(Metal::createMetal("50克金条", "AU50G", "SGE", "SGE.AU50G", YTXTime().toStringYYYYMMdd(), true, ts_shj, date_shj, date_shj_end, shjRestTime, indexConfig, 2, true));
    ret.push_back(Metal::createMetal("黄金单月延期", "AUT+N1", "SGE", "SGE.AUT+N1", YTXTime().toStringYYYYMMdd(), true, ts_shj, date_shj, date_shj_end, shjRestTime, indexConfig, 2, true));
    ret.push_back(Metal::createMetal("黄金双月延期", "AUT+N2", "SGE", "SGE.AUT+N2", YTXTime().toStringYYYYMMdd(), true, ts_shj, date_shj, date_shj_end, shjRestTime, indexConfig, 2, true));
    ret.push_back(Metal::createMetal("白银9999", "AG9999", "SGE", "SGE.AG9999", YTXTime().toStringYYYYMMdd(), true, ts_shj, date_shj, date_shj_end, shjRestTime, indexConfig, 2, true));
    ret.push_back(Metal::createMetal("白银999", "AG999", "SGE", "SGE.AG999", YTXTime().toStringYYYYMMdd(), true, ts_shj, date_shj, date_shj_end, shjRestTime, indexConfig, 2, true));
    ret.push_back(Metal::createMetal("铂金9995", "PT9995", "SGE", "SGE.PT9995", YTXTime().toStringYYYYMMdd(), true, ts_shj, date_shj, date_shj_end, shjRestTime, indexConfig, 2, true));
    //伦敦
    ret.push_back(Metal::createMetal("伦敦金", "XAU", "INAU", "INAU.XAU", YTXTime().toStringYYYYMMdd(), true, ts_gjj, date_gjj, date_gjj_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("伦敦银", "XAG", "INAU", "INAU.XAG", YTXTime().toStringYYYYMMdd(), true, ts_gjj, date_gjj, date_gjj_end, restTime, indexConfig, 3, false));
    ret.push_back(Metal::createMetal("伦敦钯金", "XPD", "INAU", "INAU.XPD", YTXTime().toStringYYYYMMdd(), true, ts_gjj, date_gjj, date_gjj_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("伦敦铂金", "XAP", "INAU", "INAU.XAP", YTXTime().toStringYYYYMMdd(), true, ts_gjj, date_gjj, date_gjj_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("香港黄金", "GT", "INAU", "INAU.GT", YTXTime().toStringYYYYMMdd(), true, ts_gjj, date_gjj, date_gjj_end, restTime, indexConfig, 0, false));
    ret.push_back(Metal::createMetal("台两黄金", "TWGD", "INAU", "INAU.TWGD", YTXTime().toStringYYYYMMdd(), true, ts_gjj, date_gjj, date_gjj_end, restTime, indexConfig, 0, false));
    
    ret.push_back(Metal::createMetal("美元指数", "USD", "INAU", "WGIN.USD", YTXTime().toStringYYYYMMdd(), true, ts_gjj, date_gjj, date_gjj_end, restTime, indexConfig, 3, false));
    ret.push_back(Metal::createMetal("原油指数", "CONC", "INAU", "WGIN.CONC", YTXTime().toStringYYYYMMdd(), true, ts_gjj, date_gjj, date_gjj_end, restTime, indexConfig, 2, false));
    
    
    ret.push_back(Metal::createMetal("粤贵银", "GDAG", "PMEC", "PMEC.GDAG", YTXTime().toStringYYYYMMdd(), true, ts_gdj, date_gdj, date_gdj_end, restTime, indexConfig, 0, false));
    ret.push_back(Metal::createMetal("粤贵钯", "GDPD", "PMEC", "PMEC.GDPD", YTXTime().toStringYYYYMMdd(), true, ts_gdj, date_gdj, date_gdj_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("粤贵铂", "GDPT", "PMEC", "PMEC.GDPT", YTXTime().toStringYYYYMMdd(), true, ts_gdj, date_gdj, date_gdj_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("粤贵油", "GDPT", "PMEC", "PMEC.YDCL", YTXTime().toStringYYYYMMdd(), true, ts_gdj, date_gdj, date_gdj_end, restTime, indexConfig, 1, false));
    
    ret.push_back(Metal::createMetal("现货白银9999", "AG1", "PMEC", "PMEC.AG1", YTXTime().toStringYYYYMMdd(), true, ts_gdj, date_gdj, date_gdj_end, restTime, indexConfig, 0, false));
    ret.push_back(Metal::createMetal("现货白银9995", "AG15", "PMEC", "PMEC.AG15", YTXTime().toStringYYYYMMdd(), true, ts_gdj, date_gdj, date_gdj_end, restTime, indexConfig, 0, false));
    ret.push_back(Metal::createMetal("现货白银100G", "AG100", "PMEC", "PMEC.AG100", YTXTime().toStringYYYYMMdd(), true, ts_gdj, date_gdj, date_gdj_end, restTime, indexConfig, 3, false));
    ret.push_back(Metal::createMetal("现货钯金9995", "PDXA", "PMEC", "PMEC.PDXA", YTXTime().toStringYYYYMMdd(), true, ts_gdj, date_gdj, date_gdj_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("现货铂金9995", "PTXA", "PMEC", "PMEC.PTXA", YTXTime().toStringYYYYMMdd(), true, ts_gdj, date_gdj, date_gdj_end, restTime, indexConfig, 2, false));
    
    //LME
    ret.push_back(Metal::createMetal("LME铜", "LMCI", "LME", "LME.LMCI", YTXTime().toStringYYYYMMdd(), true, ts_lme, date_lme, date_lme_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("LME铝", "LMAI", "LME", "LME.LMAI", YTXTime().toStringYYYYMMdd(), true, ts_lme, date_lme, date_lme_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("LME镍", "LMNI", "LME", "LME.LMNI", YTXTime().toStringYYYYMMdd(), true, ts_lme, date_lme, date_lme_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("LME铅", "LMPI", "LME", "LME.LMPI", YTXTime().toStringYYYYMMdd(), true, ts_lme, date_lme, date_lme_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("LME锌", "LMZI", "LME", "LME.LMZI", YTXTime().toStringYYYYMMdd(), true, ts_lme, date_lme, date_lme_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("LME合金", "LMAC", "LME", "LME.LMAC", YTXTime().toStringYYYYMMdd(), true, ts_lme, date_lme, date_lme_end, restTime, indexConfig, 2, false));
    ret.push_back(Metal::createMetal("LME锡", "LMSI", "LME", "LME.LMSI", YTXTime().toStringYYYYMMdd(), true, ts_lme, date_lme, date_lme_end, restTime, indexConfig, 2, false));
    
    //shfe
    ret.push_back(Metal::createMetal("沪银连续", "AG0001", "SHFE", "SHFE.AG0001", YTXTime().toStringYYYYMMdd(), true, ts_shfe, date_shfe, date_shfe_end, shfeRestTime, indexConfig, 0, true));
    
    
    //    const YTXTime date_czce(date(2001, date_time::Jan, 1), time_duration(9,0,0));
    //
    //    const YTXTime date_czce_end(date(2001, date_time::Jan, 1), time_duration(15,0,0));
    //
    //    const TimeString ts_czce = createTimeStringByTimeType(MarketTimeType::Others, Tools::YTXTime2StringYYYYMMddHHmmss(date_czce), Tools::YTXTime2StringYYYYMMddHHmmss(date_czce_end) );
    //
    //    vector<pair<time_duration, time_duration> > czceRestTime;
    //
    //    time_duration czce00(10, 15, 0);
    //    time_duration czce01(10, 30, 0);
    //
    //    time_duration czce10(11, 30, 0);
    //    time_duration czce11(13, 30, 0);
    //
    //    czceRestTime.push_back(make_pair(czce00, czce01));
    //
    //    czceRestTime.push_back(make_pair(czce10, czce11));
    //
    //    ret.push_back(Metal::createMetal("菜籽油指数", "CZCE.R00000", "TD", "CZCE.R00000", ts_czce, date_czce, date_czce_end, czceRestTime, 0, true));
    
    return ret;
}

TimeString Metal::createTimeStringByType(int t, string openTime, string endTime){
    switch (t) {
        case 0:
            return Metal::createTimeStringByTimeType(MarketTimeType::From0600To0400, openTime, endTime);
        case 1:
            return Metal::createTimeStringByTimeType(MarketTimeType::From0600To0600, openTime, endTime);
        case 2:
            return Metal::createTimeStringByTimeType(MarketTimeType::From2100To1530, openTime, endTime);
        case 3:
            return Metal::createTimeStringByTimeType(MarketTimeType::From0900To0300, openTime, endTime);
        case 4:
            return Metal::createTimeStringByTimeType(MarketTimeType::From2100To1500, openTime, endTime);
        case 5:
            return Metal::createTimeStringByTimeType(MarketTimeType::From2000To1530, openTime, endTime);
        case 6:
            return Metal::createTimeStringByTimeType(MarketTimeType::From0800To0200, openTime, endTime);
        case 7:
            return Metal::createTimeStringByTimeType(MarketTimeType::From0600To0515, openTime, endTime);
        case 8:
            return Metal::createTimeStringByTimeType(MarketTimeType::From0700To0615, openTime, endTime);
        case 9:
            return Metal::createTimeStringByTimeType(MarketTimeType::From0700To0515, openTime, endTime);
        case 10:
            return Metal::createTimeStringByTimeType(MarketTimeType::From0800To0615, openTime, endTime);
        case 11:
            return Metal::createTimeStringByTimeType(MarketTimeType::From0900To0600, openTime, endTime);
        case 12:
            return Metal::createTimeStringByTimeType(MarketTimeType::From0930To1500, openTime, endTime);
        case 13:
            return Metal::createTimeStringByTimeType(MarketTimeType::Fromzsj_r, openTime, endTime);
        case 14:
            return Metal::createTimeStringByTimeType(MarketTimeType::Fromzsj_y, openTime, endTime);
        case 15:
            return Metal::createTimeStringByTimeType(MarketTimeType::Fromdsj_r, openTime, endTime);
        case 16:
            return Metal::createTimeStringByTimeType(MarketTimeType::Fromdsj_y, openTime, endTime);
        case 17:
            return Metal::createTimeStringByTimeType(MarketTimeType::Fromsqj_r, openTime, endTime);
        case 18:
            return Metal::createTimeStringByTimeType(MarketTimeType::Fromsqj_y0, openTime, endTime);
        case 19:
            return Metal::createTimeStringByTimeType(MarketTimeType::Fromsqj_y1, openTime, endTime);
        case 20:
            return Metal::createTimeStringByTimeType(MarketTimeType::Fromsqj_y2, openTime, endTime);
        case 21:
            return Metal::createTimeStringByTimeType(MarketTimeType::Fromzjqj_r0, openTime, endTime);
        case 22:
            return Metal::createTimeStringByTimeType(MarketTimeType::Fromzjqj_r1, openTime, endTime);
        default:
            return Metal::createTimeStringByTimeType(MarketTimeType::Others, openTime, endTime);
    }
}

MarketTimeType::MarketTimeType Metal::timeTypeByTradeTime(std::string tradeTime)
{
    if (tradeTime == "540-615;630-690;810-900") {//郑商所、大商所、上交所日盘时间一致
        return MarketTimeType::Fromzsj_r;
    }
    if (tradeTime == "1260-1410;540-615;630-690;810-900") {//郑商所、大商所夜盘时间一致
        return MarketTimeType::Fromzsj_y;
    }
    if (tradeTime == "1260-1440;0-60;540-615;630-690;810-900") {//上交所夜盘
        return MarketTimeType::Fromsqj_y0;
    }
    if (tradeTime == "1260-1380;540-615;630-690;810-900") {//上交所夜盘
        return MarketTimeType::Fromsqj_y1;
    }
    if (tradeTime == "1260-1440;0-150;540-615;630-690;810-900") {//上交所夜盘
        return MarketTimeType::Fromsqj_y2;
    }
    if (tradeTime == "570-690;780-900") {//中金所日盘
        return MarketTimeType::Fromzjqj_r0;
    }
    if (tradeTime == "555-690;780-915") {//中金所日盘
        return MarketTimeType::Fromzjqj_r1;
    }
    return MarketTimeType::Others;
}

TimeString __attribute__((annotate("oclint:suppress[long method]"))) __attribute__((annotate("oclint:suppress[high ncss method]")))Metal::createTimeStringByTimeType(MarketTimeType::MarketTimeType t, string openTime, string endTime) {
    vector<string> big;
    vector<string> middle;
    vector<string> small;
    int i = 0, len1 = 0, len2 = 0, len3 = 0;
    
    switch (t) {
        case MarketTimeType::From0600To0400: {
            string strbig1[] = {"06:00", "08:00", "10:00", "12:00", "14:00", "16:00", "18:00",
                "20:00", "22:00", "00:00", "02:00", "04:00"};
            string strmiddle1[] = {"06:00", "08:45", "11:30", "14:15", "17:00", "19:45", "22:30",
                "01:15", "04:00"};
            string strsmall1[] = {"06:00", "17:00", "04:00" };

            i = 0, len1 = 12, len2 = 9, len3 = 3;
            for(i=0;i<len1;i++){
                big.push_back(strbig1[i]);
            }

            for(i=0;i<len2;i++){
                middle.push_back(strmiddle1[i]);
            }

            for(i=0;i<len3;i++){
                small.push_back(strsmall1[i]);
            }
            break;
        }
        case MarketTimeType::From0600To0600: {
            string strbig2[] = {"06:00", "09:00", "12:00", "15:00", "18:00", "21:00", "00:00", "03:00", "06:00"};
            string strmiddle2[] = {"06:00", "10:00", "14:00", "18:00", "22:00", "02:00", "06:00"};
            string strsmall2[] = {"06:00", "18:00", "06:00" };

            i = 0, len1 = 9, len2 = 7, len3 = 3;
            for(i=0;i<len1;i++){
                big.push_back(strbig2[i]);
            }

            for(i=0;i<len2;i++){
                middle.push_back(strmiddle2[i]);
            }

            for(i=0;i<len3;i++){
                small.push_back(strsmall2[i]);
            }
            break;
        }
        case MarketTimeType::From2100To1530: {
            string strbig3[] = {"21:00", "", "22:00", "", "23:00", "", "00:00", "", "01:00", "",
                "", "02:30/09:00", "", "", "10:30", "", "11:30/13:30", "", "14:30",
                "", "15:30"};
            string strmiddle3[] = {"21:00", "", "", "", "23:00", "", "",
                "", "01:00", "", "", "02:30/09:00", "", "", "", "", "11:30/13:30",
                "", "", "", "15:30"};
            string strsmall3[] = {"21:00", "15:30"};

            i = 0, len1 = 21, len2 = 21, len3 = 2;

            for(i=0;i<len1;i++){
                big.push_back(strbig3[i]);
            }

            for(i=0;i<len2;i++){
                middle.push_back(strmiddle3[i]);
            }

            for(i=0;i<len3;i++){
                small.push_back(strsmall3[i]);
            }
            break;
        }
        case MarketTimeType::From0900To0300: {
            string strbig4[] = {"09:00", "11:00", "13:00", "15:00", "17:00", "19:00", "21:00",
                "23:00", "01:00", "03:00"};
            string strmiddle4[] = {"09:00", "12:00", "15:00", "18:00", "21:00", "00:00", "03:00"};
            string strsmall4[] = {"09:00", "18:00", "03:00" };

            int i = 0, len1 = 10, len2 = 7, len3 = 3;

            for(i=0;i<len1;i++){
                big.push_back(strbig4[i]);
            }

            for(i=0;i<len2;i++){
                middle.push_back(strmiddle4[i]);
            }

            for(i=0;i<len3;i++){
                small.push_back(strsmall4[i]);
            }
            break;
        }
        case MarketTimeType::From2100To1500: {
            string strbig3[] = {"21:00", "", "22:00", "", "23:00", "", "00:00", "", "01:00", "",
                "", "02:30/09:00", "", "", "10:30", "", "11:30/13:30", "", "", "15:00"};
            string strmiddle3[] = {"21:00", "", "", "", "23:00", "", "",
                "", "01:00", "", "", "02:30/09:00", "", "", "", "", "11:30/13:30",
                "", "", "15:00"};
            string strsmall3[] = {"21:00", "15:00"};

            i = 0, len1 = 20, len2 = 20, len3 = 2;

            for(i=0;i<len1;i++){
                big.push_back(strbig3[i]);
            }

            for(i=0;i<len2;i++){
                middle.push_back(strmiddle3[i]);
            }

            for(i=0;i<len3;i++){
                small.push_back(strsmall3[i]);
            }
            break;
        }
        case MarketTimeType::From2000To1530: {
            string strbig3[] = {"20:00", "", "21:00", "", "22:00", "", "23:00", "", "00:00", "", "01:00", "",
                "", "02:30/09:00", "", "", "10:30", "", "11:30/13:30", "", "14:30",
                "", "15:30"};
            string strmiddle3[] = {"20:00", "", "", "", "22:00", "", "", "", "00:00", "", "",
                "", "", "02:30/09:00", "", "", "", "", "11:30/13:30", "", "",
                "", "15:30"};
            string strsmall3[] = {"20:00", "01:30", "15:30"};
            
            i = 0, len1 = 23, len2 = 23, len3 = 3;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig3[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle3[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall3[i]);
            }
            break;
        }
        case MarketTimeType::From0800To0200: {
            string strbig[] = {"08:00", "10:00", "12:00", "14:00", "16:00", "18:00", "20:00",
                "22:00", "00:00", "02:00"};
            string strmiddle[] = {"08:00", "11:00", "14:00", "17:00", "20:00", "23:00", "02:00"};
            string strsmall[] = {"08:00", "17:00", "02:00" };
            
            int i = 0, len1 = 10, len2 = 7, len3 = 3;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::From0600To0515: {
            string strbig[] = {
                "06:00", "", "", "", "09:00", "",
                "", "", "12:00", "", "", "",
                "15:00", "", "", "", "18:00", "",
                "", "", "21:00", "", "", "",
                "00:00", "", "", "", "03:00", "",
                "", "05:15"};
            string strmiddle[] =  {
                "06:00", "", "", "", "", "",
                "", "", "12:00", "", "", "",
                "", "", "", "", "18:00", "",
                "", "", "", "", "", "",
                "00:00", "", "", "", "", "",
                "", "05:15"};
            string strsmall[] =  {
                "06:00", "", "", "", "", "",
                "", "", "12:00", "", "", "",
                "", "", "", "", "", "",
                "", "", "", "", "", "",
                "", "", "", "", "", "",
                "", "05:15"};
            
            int i = 0, len1 = 32, len2 = 32, len3 = 32;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::From0700To0615: {
            string strbig[] = {
                "07:00", "", "", "",   "", "", "", "",
                "09:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "12:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "15:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "18:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "21:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "00:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "03:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "06:15"
            };
            string strmiddle[] =  {
                "07:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "12:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "17:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "22:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "03:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "06:15"
            };
            string strsmall[] =  {
                "07:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "18:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "06:15"
            };
            
            int i = 0, len1 = 94, len2 = 94, len3 = 94;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::From0700To0515: {
            string strbig[] = {
                "07:00", "", "", "",   "", "", "", "",
                "09:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "12:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "15:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "18:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "21:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "00:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "03:00", "", "", "",   "", "", "", "",
                "", "05:15"
            };
            string strmiddle[] =  {
                "07:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "12:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "17:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "22:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "03:00", "", "", "",   "", "", "", "",
                "", "05:15"
            };
            string strsmall[] =  {
                "07:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "18:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "05:15"
            };
            
            int i = 0, len1 = 90, len2 = 90, len3 = 90;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::From0800To0615: {
            string strbig[] = {
                "08:00", "", "", "",   "", "", "", "",
                "09:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "12:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "15:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "18:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "21:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "00:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "03:00", "", "", "",   "", "", "", "",
                "", "06:15"
            };
            string strmiddle[] =  {
                "08:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "12:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "17:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "22:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "03:00", "", "", "",   "", "", "", "",
                "", "06:15"
            };
            string strsmall[] =  {
                "08:00", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "18:00", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "", "", "",   "", "", "", "",
                "", "06:15"
            };
            
            int i = 0, len1 = 90, len2 = 90, len3 = 90;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::From0900To0600: {
            string strbig[] = {
                "09:00","","","","",
                "","","16:00","","",
                "","","","","23:00",
                "","","","","",
                "", "06:00"
            };
            string strmiddle[] =  {
                "09:00","","","","",
                "","","16:00","","",
                "","","","","23:00",
                "","","","","",
                "", "06:00"
            };
            string strsmall[] =  {
                "09:00","","","","",
                "","","","","",
                "","20:00","","","",
                "","","","","",
                "", "06:00"
            };
            
            int i = 0, len1 = 22, len2 = 22, len3 = 22;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::From0930To1500: {// 股票
            string strbig[] = {
                "09:30","11:30", "15:00"
            };
            string strmiddle[] =  {
                "09:30","11:30", "15:00"
            };
            string strsmall[] =  {
                "09:30","11:30", "15:00"
            };
            
            int i = 0, len1 = 3, len2 = 3, len3 = 3;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
            
        }
        case MarketTimeType::Fromzsj_r: {// 期货
            string strbig[] = {
                "09:00","","","","10:00","","","11:00","","","","14:00","","","",
                "15:00"
            };
            string strmiddle[] =  {
                "09:00","","","","10:00","","","11:00","","","","14:00","","","",
                "15:00"
            };
            string strsmall[] =  {
                "09:00","","","","10:00","","","11:00","","","","14:00","","","",
                "15:00"
            };
            
            int i = 0, len1 = 16, len2 = 16, len3 = 16;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::Fromzsj_y: {
            string strbig[] = {
                "21:00","","","","","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            string strmiddle[] =  {
                "21:00","","","","","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            string strsmall[] =  {
                "21:00","","","","","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            
            int i = 0, len1 = 26, len2 = 26, len3 = 26;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::Fromdsj_r: {
            string strbig[] = {
                "09:00","","","","10:00","","","11:00","","","","14:00","","","",
                "15:00"
            };
            string strmiddle[] =  {
                "09:00","","","","10:00","","","11:00","","","","14:00","","","",
                "15:00"
            };
            string strsmall[] =  {
                "09:00","","","","10:00","","","11:00","","","","14:00","","","",
                "15:00"
            };
            
            int i = 0, len1 = 16, len2 = 16, len3 = 16;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::Fromdsj_y: {
            string strbig[] = {
                "21:00","","","","","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            string strmiddle[] =  {
                "21:00","","","","","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            string strsmall[] =  {
                "21:00","","","","","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            
            int i = 0, len1 = 21, len2 = 21, len3 = 21;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::Fromsqj_r: {
            string strbig[] = {
                "09:00","","","","10:00","","","11:00","","","","14:00","","","",
                "15:00"
            };
            string strmiddle[] =  {
                "09:00","","","","10:00","","","11:00","","","","14:00","","","",
                "15:00"
            };
            string strsmall[] =  {
                "09:00","","","","10:00","","","11:00","","","","14:00","","","",
                "15:00"
            };
            
            int i = 0, len1 = 16, len2 = 16, len3 = 16;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::Fromsqj_y0: {
            string strbig[] = {
                "21:00","","","","","","","","23:00","","","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            string strmiddle[] =  {
                "21:00","","","","","","","","23:00","","","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            string strsmall[] =  {
                "21:00","","","","","","","","23:00","","","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            
            int i = 0, len1 = 32, len2 = 32, len3 = 32;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::Fromsqj_y1: {
            string strbig[] = {
                "21:00","","","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            string strmiddle[] =  {
                "21:00","","","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            string strsmall[] =  {
                "21:00","","","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            
            int i = 0, len1 = 24, len2 = 24, len3 = 24;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::Fromsqj_y2: {
            string strbig[] = {// 加空格就可以在对应的地方画直线
                "21:00","","","","","","","","23:00","","","","","","","","01:00","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            string strmiddle[] =  {
                "21:00","","","","","","","","23:00","","","","","","","","01:00","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            string strsmall[] =  {
                "21:00","","","","","","","","23:00","","","","","","","","01:00","","","","","",
                "09:00","","","","","","","","","","","","","","",
                "15:00"
            };
            
            int i = 0, len1 = 38, len2 = 38, len3 = 38;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::Fromzjqj_r0: {
            string strbig[] = {
                "09:30","","10:00","","","","11:00","","13:00","","","","14:00","","","",
                "15:00"
            };
            string strmiddle[] =  {
                "09:30","","10:00","","","","11:00","","13:00","","","","14:00","","","",
                "15:00"
            };
            string strsmall[] =  {
                "09:30","","10:00","","","","11:00","","13:00","","","","14:00","","","",
                "15:00"
            };
            
            int i = 0, len1 = 17, len2 = 17, len3 = 17;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        case MarketTimeType::Fromzjqj_r1: {
            string strbig[] = {
                "09:15","","","10:00","","","","11:00","","13:00","","","","14:00","","","",
                "15:00"
            };
            string strmiddle[] =  {
                "09:15","","","10:00","","","","11:00","","13:00","","","","14:00","","","",
                "15:00"
            };
            string strsmall[] =  {
                "09:15","","","10:00","","","","11:00","","13:00","","","","14:00","","","",
                "15:00"
            };
            
            int i = 0, len1 = 18, len2 = 18, len3 = 18;
            
            for(i=0;i<len1;i++){
                big.push_back(strbig[i]);
            }
            
            for(i=0;i<len2;i++){
                middle.push_back(strmiddle[i]);
            }
            
            for(i=0;i<len3;i++){
                small.push_back(strsmall[i]);
            }
            break;
        }
        default:
            big.push_back(openTime);
            big.push_back(endTime);
            middle.push_back(openTime);
            middle.push_back(endTime);
            small.push_back(openTime);
            small.push_back(endTime);
            break;
    }
    return TimeString(big, middle, small);
}

string IntToString(int minute)
{
    int hour=0;
    std::string str;
    char tmpch[100];
    hour=minute/60;
    minute=minute%60;
    if(hour<10&&minute<10)
        sprintf(tmpch,"0%d:0%d",hour,minute);
    else if(hour<10&&minute>=10)
        sprintf(tmpch,"0%d:%d",hour,minute);
    else if(hour>=10&&minute>=10)
        sprintf(tmpch,"%d:%d",hour,minute);
    else if(hour>=10&&minute<10)
        sprintf(tmpch,"%d:0%d",hour,minute);
    str=tmpch;
    return str;
}
TimeString __attribute__((annotate("oclint:suppress[long method]"))) __attribute__((annotate("oclint:suppress[high ncss method]")))Metal::createTimeStringBytradeTime(std::string tradeTime) {
    for (int i=0; i<tradeTime.length(); i++) {
        if (tradeTime[i] == '-' || tradeTime[i] == ';')
            tradeTime[i] = ' ';
    }
    
    vector<int> array;
    stringstream ss(tradeTime);
    int temp;
    while (ss >> temp)
        array.push_back(temp);
    
    int pairCount = (int)array.size() / 2;
    vector<string> big;
    for (int i = 0; i < pairCount; i++) {
        for (int j = array[i*2]; j <= array[i*2+1]; j++) {
            if (j == array[0] || j == array[pairCount*2-1]) {
                big.push_back(IntToString(j));
            } else if (j == array[i*2]) {
                big.push_back(IntToString(array[i*2-1])+ "/" + IntToString(j));
            } else {
                big.push_back("");
            }
        }
    }
       
    return TimeString(big, big, big);
}

ytx::Rect Metal::createRowByTimeString(TimeString t){
    return ytx::Rect((int)t.big.size()-1, (int)t.middle.size()-1, (int)t.small.size()-1);
}

Metal Metal::createMetal(string name, string nickname, string marketType, string id, string currentDate ,int stepDay, TimeString ts, YTXTime opentime, YTXTime endtime, vector<pair<YTXTime, YTXTime> > restTime, map<IndexType::IndexType, IndexConfig> indexConfig, int toFix, bool hasVolume, Rect column) {
    Rect row = Metal::createRowByTimeString(ts);
    
    int restTimeMinutes = 0;
    
    for (vector<pair<YTXTime, YTXTime> >::iterator it = restTime.begin(); it != restTime.end() ; ++it) {
        pair<YTXTime, YTXTime> p = (*it);
        restTimeMinutes += (p.second - p.first) / 60;
    }
    int dataSum = (int)(restTimeMinutes);
    
    return Metal(name, nickname, dataSum, marketType, id, currentDate, stepDay, ts, row, column, opentime, endtime, restTime, indexConfig, toFix, hasVolume);
}

bool Metal::checkData(map<string, string> data){
    map<string, string >::iterator end = data.end();
    return data.find("name") != end && data.find("nickname") != end && data.find("marketType") != end && data.find("id") != end && data.find("currentDate") != end && data.find("timeType") != end && data.find("openTime") != end && data.find("endTime") != end && data.find("restTime") != end && data.find("toFix") != end && data.find("hasVolume") != end ;
}

string Metal::getCurrentDate() {
    return currentDate;
}

int Metal::getStepDay() {
    return stepDay;
}

string Metal::getName() {
    return name;
}

string Metal::getNickname() {
    return nickname;
}

int Metal::getDataSum() {
    return dataSum;
}

string Metal::getMarketType() {
    return marketType;
}

int Metal::getToFix() {
    return toFix;
}

string Metal::getId() {
    return id;
}

int Metal::getThreshold() {
    return threshold;
}

int Metal::getBuffer() {
    return buffer;
}

YTXTime Metal::getOpenTime() {
    return openTime;
}

YTXTime Metal::getCloseTime() {
    return closeTime;
}

TimeString Metal::getTimeString() {
    return timeString;
}

bool Metal::isHasVolume() {
    return hasVolume;
}

ytx::Rect Metal::getRow() {
    return row;
}

ytx::Rect Metal::getColumn() {
    return column;
}

vector<pair<YTXTime, YTXTime> > Metal::getRestTime()
{
    return restTime;
}

map<IndexType::IndexType, IndexConfig> Metal::getIndexConfig(){
    return indexConfig;
}

double Metal::getAvgAccuracy(string id){
    double chushu = 1.0;

    if ( id == "SGE.AG9999" || id == "SGE.AG999" || id == "SGE.AGT+D" ){
        chushu = 1.0;
    }
    else if ( id == "SGE.AU100G"){// || id == "MAUT+D"
        chushu = 100.0;
    }
    else if ( id == "SGE.AU9999" ){
        chushu = 10.0;
    }
    else if ( id == "SGE.AU50G" ){
        chushu = 50.0;
    }
    else if ( id == "SGE.AUT+D" || id == "SGE.AU9995" || id == "SGE.PT9995" || id == "SGE.AUT+N1" || id == "SGE.AUT+N2" ){
        chushu = 1000.0;
    }

    return chushu;
}
